#!/bin/sh
PATH=$PATH:/usr/local/opt/gettext/bin

rm jubler.pot

( cd ../.. ; xgettext  --from-code=utf-8 -k__ `find modules -name *.java` -i -o resources/i18n/jubler.pot )

if [ "$1" != "" ] ; then
	WHAT=$1.po
else
	WHAT=`ls *.po`
fi


rm -rf node_modules package-lock.json
npm install po2json

for i in $WHAT ; do
	LNG=`echo $i | sed -e 's/\.po$//g'`
	echo Remaking po file for language \"$LNG\"
	msgmerge --no-fuzzy-matching --update --indent --sort-by-file --backup=none $LNG.po jubler.pot 
        ./node_modules/po2json/bin/po2json $LNG.po $LNG.json -f mf
done

rm -rf node_modules package-lock.json
